import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Button } from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: '表单名称',
    align: 'center',
    dataIndex: 'formName',
  },
  {
    title: '表单类型',
    align: 'center',
    dataIndex: 'formTypeStr',
  },
  {
    title: '表单url',
    align: 'center',
    dataIndex: 'formUrl',
  },
  {
    title: '表单内容',
    align: 'center',
    dataIndex: 'formContent',
  },
  {
    title: '创建人员',
    align: 'center',
    dataIndex: 'createUserStr',
  },
  {
    title: '更新人员',
    align: 'center',
    dataIndex: 'updateUserStr',
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    component: 'Input',
    show: false,
  },
  {
    field: 'formName',
    label: '表单名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'formType',
    label: '表单类型',
    component: 'ApiSelect',
    required: true,
    defaultValue: 'inner_link',
    componentProps: {
      dictCode: 'form_type',
    },
  },
  {
    field: 'formDesign',
    label: '配置表单',
    component: 'Input',
    ifShow: ({ values }) => values.formType === 'json',
    render: () => {
      return h(
        Button,
        {
          type: 'primary',
          onClick: () => {
            console.log('跳转');
          },
        },
        '配置表单',
      );
    },
  },
  {
    field: 'formUrl',
    label: '表单url',
    component: 'Input',
    helpMessage:
      '如果是系统内的代码表单 需要从views下的文件夹开始 如 module/page/index.vue',
    ifShow: ({ values }) =>
      values.formType === 'inner_link' || values.formType === 'outer_link',
    required: true,
  },
  {
    field: 'formContent',
    label: '表单内容',
    component: 'Input',
    required: true,
    ifShow: ({ values }) => values.formType === 'json_form',
  },
  {
    field: 'remark',
    label: '备注',
    component: 'Input',
    required: true,
    colProps: {
      span: 24,
    },
  },
];
